package cn.lizhangqu.kb.handler;

import org.json.JSONException;
import org.json.JSONObject;

import cn.lizhangqu.kb.model.Report;

/**
 * Created by 柯尊诚 on 2015/11/6.
 * kzc
 */
public class ReportJsonResponseHandler extends JsonResponseHandler<Report> {

    public final static String JSON_KEY_CREATEDATE = "createDate";
    public final static String JSON_KEY_CREATETIME = "createTime";
    public final static String JSON_KEY_UPDDATE = "updDate";
    public final static String JSON_KEY_UPDTIME = "updTime";
    public final static String JSON_KEY_RELEASEDATE = "releaseDate";
    public final static String JSON_KEY_SYSID = "sysId";
    public final static String JSON_KEY_TITLE = "title";
    public final static String JSON_KEY_CONTENT = "content";
    public final static String JSON_KEY_EDITORAUTHOR = "editorAuthor";
    public final static String JSON_KEY_SHOWSEAT = "showSeat";
    public final static String JSON_KEY_DISPLAY = "display";
    public final static String JSON_KEY_IMAGE = "image";

    @Override
    protected Report parseItem(JSONObject json) throws JSONException {

        Report report = new Report();

        if (hasKeyValue(json, JSON_KEY_CREATEDATE)) {
            report.setCreateDate(json.getString(JSON_KEY_CREATEDATE));
        }

        if (hasKeyValue(json, JSON_KEY_CREATETIME)) {
            report.setCreateTime(json.getString(JSON_KEY_CREATETIME));
        }

        if (hasKeyValue(json, JSON_KEY_UPDDATE)) {
            report.setUpdDate(json.getString(JSON_KEY_UPDDATE));
        }

        if (hasKeyValue(json, JSON_KEY_UPDTIME)) {
            report.setUpdTime(json.getString(JSON_KEY_UPDTIME));
        }

        if (hasKeyValue(json, JSON_KEY_RELEASEDATE)) {
            report.setReleaseDate(json.getString(JSON_KEY_RELEASEDATE));
        }

        if (hasKeyValue(json, JSON_KEY_SYSID)) {
            report.setId(json.getString(JSON_KEY_SYSID));
        }

        if (hasKeyValue(json, JSON_KEY_TITLE)) {
            report.setTitle(json.getString(JSON_KEY_TITLE));
        }

        if (hasKeyValue(json, JSON_KEY_IMAGE)) {
            report.setImage(json.getString(JSON_KEY_IMAGE));
        }

        if (hasKeyValue(json, JSON_KEY_CONTENT)) {
            report.setContent(json.getString(JSON_KEY_CONTENT));
        }

        if (hasKeyValue(json, JSON_KEY_EDITORAUTHOR)) {
            report.setEditorAuthor(json.getString(JSON_KEY_EDITORAUTHOR));
        }

        if (hasKeyValue(json, JSON_KEY_SHOWSEAT)) {
            report.setShowSeat(json.getString(JSON_KEY_SHOWSEAT));
        }

        if (hasKeyValue(json, JSON_KEY_DISPLAY)) {
            report.setDisplay(json.getString(JSON_KEY_DISPLAY));
        }


        return report;
    }
}
